/*
 * Copyright (c) 2016 The ZLToolKit project authors. All Rights Reserved.
 *
 * This file is part of ZLToolKit(https://github.com/xia-chu/ZLToolKit).
 *
 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
 */

#include <signal.h>
#include <iostream>
#include "Util/util.h"
#include "Util/logger.h"
#include "Network/Buffer.h"

using namespace std;
using namespace toolkit;

#define PKT_SIZE 1318
void test_BufferLikeString() {
    BufferLikeString buf;
    FILE* fp_origin = fopen("bufcontent.txt","wb");
    FILE* fp_bufout = fopen("bufoutput.txt","wb");
    for(int i = 0; i < 10; i++) {
        char buffer[PKT_SIZE] = {0};
        memset(buffer,'A'+i,PKT_SIZE);
        fwrite(buffer,1,PKT_SIZE,fp_origin);
        buf.append(buffer,sizeof(buffer));
    }
    fwrite(buf.data(),1,buf.size(),fp_bufout);
    fclose(fp_origin);
    fclose(fp_bufout);
    
}
int main() {
    //设置日志
    Logger::Instance().add(std::make_shared<ConsoleChannel>());
    Logger::Instance().setWriter(std::make_shared<AsyncLogWriter>());
    test_BufferLikeString();
    return 0;
}
